<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>props</title>
    <script src="lib/react/react.development.js"></script>
    <script src="lib/react/react-dom.development.js"></script>
    <script src="lib/babel.min.js"></script>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
      let message = "前端小溪";
      class HelloWorld extends React.Component {
        render() {
          // 不能修改props, 否则报错assign to read only property 'value' of object
          //   this.props.value = "ds";
          return (
            <div>
              <h2>
                {message}:{this.props.value} -- 组件名:{" "}
                {this.props.componentName}
              </h2>
            </div>
          );
        }
      }

      class Demos extends React.Component {
        render() {
          return (
            <div>
              <HelloWorld value="1" />
              <HelloWorld value="2" />
              <HelloWorld value="3" componentName={message} />
            </div>
          );
        }
      }

      ReactDOM.render(<Demos />, document.getElementById("root"));
    </script>
  </body>
</html>
